<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>随机数列表操作</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <ul>
            <!-- 列表渲染 -->
            <li v-for="(item, index) in numberList">
                {{ item }}
                <!-- 删除按钮 -->
                <button @click="deleteItem(index)">删除</button> 
            </li>
        </ul>
        <button @click="generateNumber">生成</button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                numberList: []
            },
            methods: {
                generateNumber() {
                    this.numberList.push(Math.floor(Math.random() * 20)); //生成随机数
                },
                deleteItem(index) {
                    this.numberList.splice(index, 1); // 删除数组中的元素
                }
            }
        });
    </script>
</body>

</html>